package procsim;

import java.awt.*;
import java.util.*;

public abstract class PaintTab extends Canvas {
    protected ArrayList<GraphicalElement> elements = new ArrayList<GraphicalElement>();
    protected ArrayList<GraphicalLine> lines = new ArrayList<GraphicalLine>();
    protected Paint parent;
    public PaintTab(Paint parent) {
        this.parent=parent;
        setBackground(Color.WHITE);
    }
    @Override
    public void paint(Graphics g){
        Graphics2D gnew = (Graphics2D)g;
        Iterator iter = elements.iterator();
        while(iter.hasNext())
            ((GraphicalElement)iter.next()).drawIt(gnew);
        iter = lines.iterator();
        while(iter.hasNext())
            ((GraphicalLine)iter.next()).drawIt(gnew, this);
    }
    public void changeTab(int i) {
        parent.setSelectedTab(i);
    }
}
